[C#] LINQ Group By


Feb 10, 2023

In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

OOP - 4 抽象類別與介面 (1)

OOP - 4 抽象類別與介面 (1)

[ 筆記 ] React 04 - 如何寫 CSS

[ 筆記 ] React 04 - 如何寫 CSS

Props  觀念與使用

Props 觀念與使用






留言討論